﻿<!DOCTYPE>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <title>热表返修开卡主页面</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
</head>
<body>
    <div id="tt" class="easyui-tabs" style="width: 100%;">
        <div title="待返修" style="padding: 3px; display: none;">
            <div id="reMainSec">
                <div class="panelSection">
                    <div class="easyui-panel " title="查询区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                        <form id="queryForm" action="">
                        <div style="margin: 3px 0px 3px 3px">
                            <div style="float: left;">
                                <div class="divLabel" style="margin-bottom: 5px; color: Red">
                                    订单号：</div>
                                <input id="txtMfgOrderName" name="mfgOrderName" class="easyui-textbox" style="width: 150px;
                                    height: 20px" />
                            </div>
                            <div style="float: left; margin-left: 10px">
                                <div class="divLabel" style="margin-bottom: 5px">
                                    件号：</div>
                                <input id="txtProductName" name="productName" class="easyui-textbox" style="width: 150px;
                                    height: 20px" />
                            </div>
                            <div style="float: left; margin-left: 10px">
                                <div class="divLabel" style="margin-bottom: 5px">
                                    批次号：</div>
                                <input id="txtContainerName" name="containerName" class="easyui-textbox" style="width: 150px;
                                    height: 20px" />
                            </div>
                            <div style="float: left; margin-left: 20px">
                                <button id="btnSearch" class="easyui-linkbutton" type="button" style="margin-top: 16px;
                                    width: 100px">
                                    查询</button>
                                <button id="btnReset" class="easyui-linkbutton" type="button" style="margin-top: 16px;
                                    margin-left: 5px; width: 60px">
                                    重置</button>
                            </div>
                            <div style="clear: both">
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
                <div class="panelSection">
                    <div class="easyui-panel " title="结果区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                        <div style="margin: 3px 0px 3px 3px; float: left; width: 99%">
                            <table id="gdContainerInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                                data-options="rownumbers:true,singleSelect:true,selectOnCheck:true,fitColumns:true">
                            </table>
                            <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                    layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]  
                ">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panelSection">
                    <div class="easyui-panel " title="按钮区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                        <div style="margin: 3px 0px 3px 3px">
                            <button id="btnStart" class="easyui-linkbutton" type="button" style="width: 120px;
                                height: 24px;">
                                返修开卡</button>
                        </div>
                    </div>
                </div>
            </div>
            <!--开卡弹窗页面-->
            <div id="dg" style="padding: 20px 0 0 0; display: none; width: 800px; height: 450px"
                data-options="title:'辅材消耗定额编辑'">
                <div id="mainForm">
                    <div class="ufcSectionStyle">
                        <span class="ufcSectionSpanStyle">批次数据填写区域</span>
                    </div>
                    <div style="margin: 3px 0 3px 3px;">
                        <div style="float: left; width: 60%">
                            <div style="margin-top: 10px;">
                                <div style="float: left; margin-left: 0px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        返修批次：</div>
                                    <input id="txtFaContainerName" class="easyui-textbox" style="width: 200px; height: 20px;"
                                        readonly />
                                </div>
                                <div style="float: left; margin-left: 20px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        返修数量：</div>
                                    <input id="txtQty" class="easyui-textbox" style="width: 80px; height: 20px" readonly />
                                </div>
                                <div style="float: left; margin-left: 20px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        返修工步：</div>
                                    <input id="txtStepInfoName" class="easyui-textbox" style="width: 100px; height: 20px"
                                        readonly />
                                </div>
                                <div style="clear: both;">
                                </div>
                            </div>
                            <div style="margin-top: 20px;">
                                <div style="float: left; margin-left: 0px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        件号：</div>
                                    <select style="width: 200px; height: 20px" id="selProductNo" data-options="editable:false,panelHeight:'auto'"
                                        class="easyui-combobox">
                                    </select>
                                </div>
                                <div style="float: left; margin-left: 20px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        工艺路线：</div>
                                    <select style="width: 200px; height: 20px" id="selWorkflowName" data-options="editable:false,panelHeight:'auto'"
                                        class="easyui-combobox">
                                    </select>
                                </div>
                                <div style="clear: both;">
                                </div>
                            </div>
                            <div style="margin-top: 20px;">
                                <div style="float: left;">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        开始工序：</div>
                                    <select style="width: 200px; height: 20px" id="selStartWorkflowStep" data-options="editable:false,panelHeight:'auto'"
                                        class="easyui-combobox">
                                    </select>
                                </div>
                                <div style="float: left;margin-left: 20px">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        开始工步：</div>
                                    <select style="width: 200px; height: 20px" id="selStartStepInfo" data-options="editable:false,panelHeight:'auto'"
                                        class="easyui-combobox">
                                    </select>
                                </div>
                                <div style="clear: both;">
                                </div>
                            </div>
                            <div style="margin-top: 20px;">
                                <div style="float: left;">
                                    <div class="divLabel" style="margin-bottom: 5px">
                                        备注：</div>
                                    <input id="txtNotes" class="easyui-textbox" style="width: 420px; height: 40px" data-options="multiline:true" />
                                </div>
                                <div style="clear: both;">
                                </div>
                            </div>
                        </div>
                        <div style="float: left; width: 40%">
                            <div style="margin-top: 10px;">
                                <div class="divLabel" style="margin-bottom: 5px">
                                    子序号：</div>
                                <table id="gdChildContainer" class="easyui-datagrid" style="width: 300px; height: 250px;
                                    margin-top: 3px">
                                </table>
                            </div>
                        </div>
                        <div style="clear: both;">
                        </div>
                    </div>
                    <div style="margin-top: 3px;" id="btnSection">
                        <div class="ufcSectionStyle">
                            <span class="ufcSectionSpanStyle">按钮区域</span>
                        </div>
                        <div style="margin: 10px 0px 3px 3px" id="btnFormSec">
                            <a href="#" id="btnStartCon" class="easyui-linkbutton" style="width: 120px;">开卡</a>
                            <a href="#" id="btnClose" class="easyui-linkbutton" style="width: 80px; margin-left: 10px;">
                                关闭</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--已返修-->
        <div title="已返修" style="padding: 3px; display: none;">
            <div class="panelSection">
                <div class="easyui-panel " title="查询区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                    <form id="queryForm1" action="">
                    <div style="margin: 3px 0px 3px 3px">
                        <div style="float: left;">
                            <div class="divLabel" style="margin-bottom: 5px; color: Red">
                                订单号：</div>
                            <input id="txtEnMfgOrderName" name="mfgOrderName" class="easyui-textbox" style="width: 150px;
                                height: 20px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                件号：</div>
                            <input id="txtEnProductName" name="productName" class="easyui-textbox" style="width: 150px;
                                height: 20px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                批次号：</div>
                            <input id="txtEnContainerName" name="containerName" class="easyui-textbox" style="width: 150px;
                                height: 20px" />
                        </div>
                        <div style="float: left; margin-left: 10px">
                            <div class="divLabel" style="margin-bottom: 5px">
                                开卡时间：</div>
                            <input id="txtStartDate" name="startDate" class="easyui-datebox" style="width: 150px;
                                height: 20px" />
                        </div>
                        <div style="float: left; margin-left: 20px">
                            <button id="btnEnSearch" class="easyui-linkbutton" type="button" style="margin-top: 16px;
                                width: 100px">
                                查询</button>
                            <button id="btnEnReset" class="easyui-linkbutton" type="button" style="margin-top: 16px;
                                margin-left: 5px; width: 60px">
                                重置</button>
                        </div>
                        <div style="clear: both">
                        </div>
                    </div>
                    </form>
                </div>
            </div>
            <div class="panelSection">
                <div class="easyui-panel " title="结果区域" style="padding: 3px; width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false">
                    <div style="margin: 3px 0px 3px 3px; float: left; width: 99%">
                        <table id="gdReContainerInfo" class="easyui-datagrid" style="width: 100%; height: 350px"
                            data-options="rownumbers:true,singleSelect:true,selectOnCheck:true,fitColumns:true">
                        </table>
                        <div id="epp" style="float: right" class="easyui-pagination" data-options="   
                    layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                    buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGoEn'
                    }]  
                ">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/ReferenceJsLib.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    /*
    创建人：zhangrj
    日期：2025-01-13
    描述：热表返修开卡主页面
    */
    var page = {
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ReBiaoConainer/RbRepairContainerStartHandler.ashx",
        init: function () {
            rePage.init();
            enRePage.init();
        },
        //post数据（路径，参数，是否异步，成功返回方法）
        post: function (url, param, async, callback) {
            $.ajax({
                type: "Post",
                url: url,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                    rePage.enableBtn();
                }
            });
        }
    };
    /*
    ----待返修页面
    */
    var rePage = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        selectedData: null,
        //初始化页面
        init: function () {
            rePage.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdContainerInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: rePage.pageTotal,
                        pageSize: rePage.pageSize,
                        pageNumber: rePage.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'MFGORDERNAME', title: '订单', width: 150 },
                 { field: 'PRODUCTNAME', title: '零件号', width: 200 },
                 { field: 'CONTAINERNAME', title: '批次号', width: 300 },
                 { field: 'QTY', title: '在制数', width: 100 },
                 { field: 'STEPNO', title: '返修工步号', width: 120 },
                 { field: 'STEPNAME', title: '返修工步名', width: 150 },
                 { field: 'REWORKQTY', title: '返修数', width: 100 }
                ]]
            });
            //子序号列表加载
            $("#gdChildContainer").datagrid({
                columns: [[
                 { field: 'ck', title: '选择', checkbox: true },
                 { field: 'CONTAINERNAME', title: '子序号批次', width: 350 }
                ]]
            });
            //查询按钮
            $('#btnSearch').on("click", function () {
                rePage.clearPage(false, true, true);
                rePage.pageNumber = 1;
                rePage.search();
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    rePage.pageSize = pageSize; rePage.pageNumber = pageNumber;
                    rePage.search();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                rePage.pageNumber = pageNumber;
                rePage.search();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                rePage.clearPage(true, true, true);
            });
            //扫描批次事件
            $('#txtMfgOrderName').textbox({
                onChange: function (n, o) {
                    rePage.pageNumber = 1;
                    rePage.search();
                }
            });
            //返修开卡
            $('#btnStart').on("click", function () {
                rePage.clearPage(false, false, true);
                rePage.disableBtn();
                rePage.openStartForm();
            });
            //弹窗开卡按钮
            $('#btnStartCon').on("click", function () {
                rePage.disableBtn();
                rePage.start();
            });
            //弹窗关闭按钮
            $('#btnClose').on("click", function () {
                $('#dg').dialog("close");
            });
        },
        //查询
        search: function () {
            rePage.disableBtn();
            var params = {
                pageSize: rePage.pageSize,
                pageIndex: rePage.pageNumber
            };
            var datas = $("#queryForm").serializeArray();
            $.each(datas, function () {
                params[this.name] = this.value;
            });
            var formData = {
                action: "GetNeedRepairContainerList",
                params: JSON.stringify(params)
            };
            page.post(page.ajaxUrl, formData, true, function (res) {
                rePage.enableBtn();
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                rePage.pageTotal = res.RowCount;
                $("#gdContainerInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //打开开卡弹窗
        openStartForm: function () {
            rePage.selectedData = null;
            var selected = $("#gdContainerInfo").datagrid("getChecked");
            if (selected.length === 0) {
                displayMessage("请选择数据", false);
                rePage.enableBtn();
                return;
            }
            if (selected.length > 1) {
                displayMessage("只能选择单个批次进行返修开卡", false);
                rePage.enableBtn();
                return;
            }
            page.post(page.ajaxUrl, { action: "GetRepairContainerStartInfo", selectedData: JSON.stringify(selected[0]) }, true, function (res) {
                if (!res.Result) {
                    rePage.enableBtn();
                    displayMessage(res.Message, res.Result);
                    return;
                }
                rePage.bindPageData(res.DBDataSet, selected[0]);
                $('#dg').dialog({
                    onClose: function () {
                        rePage.enableBtn();
                    }
                });
            });
        },
        //绑定页面数据
        bindPageData: function (datas, selectedData) {
            $("#selWorkflowName").combo('clear');
            $("#selWorkflowName").combo("panel").empty();
            $("#selStartWorkflowStep").combo('clear');
            $("#selStartWorkflowStep").combo("panel").empty();
            $("#selStartStepInfo").combo('clear');
            $("#selStartStepInfo").combo("panel").empty();
            $("#txtFaContainerName").textbox('setValue', selectedData.CONTAINERNAME); //返修批次
            $("#txtQty").textbox('setValue', selectedData.REWORKQTY); //返修数
            $("#txtStepInfoName").textbox('setValue', selectedData.STEPNAME); //返修工步名
            //件号
            $("#selProductNo").combobox({
                valueField: 'PRODUCTID',
                textField: 'PRODUCTNAME',
                panelHeight: 200,
                data: datas.subSectionProductDt, //下拉数据
                value: selectedData.PRODUCTID, //默认值
                onSelect: function (record) {
                    rePage.bindWorkFlowListDatas(record.PRODUCTNAME);
                }
            });
            if (datas.dtChildCon !== undefined) {
                $("#gdChildContainer").datagrid('loadData', { rows: datas.dtChildCon });
            }
            rePage.selectedData = selectedData;
        },
        //动态绑定工艺下拉列表
        bindWorkFlowListDatas: function (productName) {
            clearMessage();
            page.post(page.ajaxUrl, { action: "GetWorkFlowListDatas", productName: productName }, true, function (res) {
                if (res.Result) {
                    $("#selWorkflowName").combo('clear');
                    $("#selWorkflowName").combobox({
                        valueField: 'WORKFLOWID',
                        textField: 'WORKFLOWNAME',
                        panelHeight: 200,
                        data: res.DBTable, //下拉数据
                        value: res.DBTable[0].WorkflowID, //默认值
                        onSelect: function (record) {
                            rePage.bindStepListDatas(record.WORKFLOWID); //绑定工序列表
                        }
                    });
                }
                else {
                    $("#selWorkflowName").combo('clear');
                    $("#selWorkflowName").combo("panel").empty();
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combo("panel").empty();
                    displayMessage(res.Message, false);
                }
            });
        },
        //动态绑定工序下拉列表
        bindStepListDatas: function (workflowId) {
            clearMessage();
            page.post(page.ajaxUrl, { action: "GetStepListDatas", workFlowID: workflowId }, true, function (res) {
                //开始工序
                if (res.Result) {
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combobox({
                        valueField: 'WORKFLOWSTEPID',
                        textField: 'WORKFLOWSTEPNAME',
                        panelHeight: 200,
                        data: res.DBTable, //下拉数据
                        value: res.DBTable[0].WORKFLOWSTEPID, //默认值
                        onSelect: function (record) {
                            rePage.bindStepInfoDatas(record.WORKFLOWSTEPID); //绑定工步列表
                        }
                    });
                }
                else {
                    $("#selStartWorkflowStep").combo('clear');
                    $("#selStartWorkflowStep").combo("panel").empty();
                    displayMessage(res.Message, false);
                }
            });
        },
        //动态绑定工步下拉列表
        bindStepInfoDatas: function (workflowStepId) {
            clearMessage();
            page.post(page.ajaxUrl, { action: "GetStepInfoList", workflowStepId: workflowStepId }, true, function (res) {
                //开始工步
                if (res.Result) {
                    $("#selStartStepInfo").combo('clear');
                    $("#selStartStepInfo").combobox({
                        valueField: 'STEPINFOID',
                        textField: 'STEPDESC',
                        panelHeight: 200,
                        data: res.DBTable, //下拉数据
                        value: res.DBTable[0].STEPINFOID //默认值
                    });
                }
                else {
                    $("#selStartStepInfo").combo('clear');
                    $("#selStartStepInfo").combo("panel").empty();
                    displayMessage(res.Message, false);
                }
            });
        },
        //开卡
        start: function () {
            rePage.disableFormBtn();
            var resData = rePage.isValidData(); //验证并获取页面数据
            if (!resData.res) {
                displayMessage(resData.mes, false);
                rePage.enableFormBtn();
                return;
            }
            page.post(page.ajaxUrl, { action: "StartReContainer", params: JSON.stringify([resData.datas]), childContainer: JSON.stringify(resData.childContainer) }, true, function (res) {
                if (res.Result) {
                    $('#dg').dialog("close");
                    rePage.clearPage(false, true, true);
                    rePage.search();
                }
                rePage.enableFormBtn();
                displayMessage(res.Message, res.Result);
            });
        },
        //验证填写数据
        isValidData: function () {
            var resObj = { res: false, mes: "", datas: {}, childContainer: [] };
            resObj.datas.faContainerName = $("#txtFaContainerName").textbox('getValue'); //返修批次
            resObj.datas.qty = $("#txtQty").textbox('getValue'); //返修数
            resObj.datas.stepInfoID = rePage.selectedData.STEPINFOID; //返修工步ID
            resObj.datas.notes = $("#txtNotes").textbox('getText'); //备注
            if (isNullOrWhiteSpaceStr(resObj.datas.faContainerName)) {
                resObj.mes = "未选择返修批次";
                return resObj;
            }
            resObj.datas.productID = $("#selProductNo").combobox('getValue'); //件号ID
            resObj.datas.productName = $("#selProductNo").combobox('getText'); //件号名
            if (isNullOrWhiteSpaceStr(resObj.datas.productID)) {
                resObj.mes = "未选择件号";
                return resObj;
            }
            resObj.datas.WorkflowID = $("#selWorkflowName").combobox('getValue'); //工艺路线ID
            resObj.datas.WorkflowName = $("#selWorkflowName").combobox('getText'); //工艺路线名
            if (isNullOrWhiteSpaceStr(resObj.datas.WorkflowID)) {
                resObj.mes = "未选择工艺路线";
                return resObj;
            }
            resObj.datas.startWorkflowStep = $("#selStartWorkflowStep").combobox('getValue'); //开始工序
            resObj.datas.startWorkflowStepName = $("#selStartWorkflowStep").combobox('getText'); //开始工序名
            if (isNullOrWhiteSpaceStr(resObj.datas.startWorkflowStep)) {
                resObj.mes = "未选择开始工序";
                return resObj;
            }
            resObj.datas.startStepInfoID = $("#selStartStepInfo").combobox('getValue'); //开始工步ID
            if (isNullOrWhiteSpaceStr(resObj.datas.startStepInfoID)) {
                resObj.mes = "未选择开始工步";
                return resObj;
            }
            if (rePage.selectedData.CONTAINERTYPE === 3) {
                resObj.childContainer = $("#gdChildContainer").datagrid('getChecked');
                if (resObj.childContainer.length === 0) {
                    resObj.mes = "请选择返修子序号";
                    return resObj;
                }
            }
            resObj.res = true;
            return resObj;
        },
        //禁用主页面按钮
        disableBtn: function () {
            $("#reMainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('disable');
            });
        },
        //启用主页面按钮
        enableBtn: function () {
            $("#reMainSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('enable');
            });
        },
        //禁用弹窗页面按钮
        disableFormBtn: function () {
            $("#btnFormSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('disable');
            });
        },
        //启用弹窗页面按钮
        enableFormBtn: function () {
            $("#btnFormSec").find(".easyui-linkbutton").each(function () {
                $(this).linkbutton('enable');
            });
        },
        //清除页面（查询区域，列表区域，是否清空消息）
        clearPage: function (query, list, msg) {
            if (query) {
                $("#txtMfgOrderName").textbox("setValue", "");
                $("#txtProductName").textbox("setValue", "");
                $("#txtContainerName").textbox("setValue", "");
                rePage.pageNumber = 1; rePage.pageTotal = 0
                $('#pp').pagination('refresh', {
                    total: rePage.pageTotal,
                    pageSize: rePage.pageSize,
                    pageNumber: rePage.pageNumber
                });
            }
            if (list) {
                rePage.pageNumber = 1; rePage.pageTotal = 0
                clearEasyuiDataGrid("gdContainerInfo"); //清空列表
            }
            if (msg) {
                clearMessage();
            }
        }
    };

    /*
    ----已返修页面
    */
    var enRePage = {
        pageTotal: 0,
        pageSize: 20,
        pageNumber: 1,
        //初始化页面
        init: function () {
            enRePage.bind();
            customizedEasyuiPagination('epp'); //定制化分页
        },
        //页面事件绑定
        bind: function () {
            //列表加载
            $("#gdReContainerInfo").datagrid({
                onLoadSuccess: function (data) {
                    $('#epp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: enRePage.pageTotal,
                        pageSize: enRePage.pageSize,
                        pageNumber: enRePage.pageNumber
                    });
                    customizedEasyuiPagination('epp'); //定制化分页
                },
                columns: [[
                 { field: 'MFGORDERNAME', title: '订单', width: 120 },
                 { field: 'PRODUCTNAME', title: '零件号', width: 150 },
                 { field: 'CONTAINERNAME', title: '返修批次号', width: 300 },
                 { field: 'QTY', title: '在制数', width: 80 },
                 { field: 'STARTDATE', title: '开卡时间', width: 120, formatter: function (value, row, index) {
                     if (!isNullOrWhiteSpaceStr(value)) {
                         return dayjs(value).format('YYYY-MM-DD');
                     }
                 } 
                 },
                 { field: 'FACONTAINERNAME', title: '主批次名', width: 300 },
                 { field: 'STEPNO', title: '返修工步号', width: 100 },
                 { field: 'STEPNAME', title: '返修工步名', width: 100 }
                ]]
            });
            //查询按钮
            $('#btnEnSearch').on("click", function () {
                enRePage.clearPage(false, true, true);
                enRePage.pageNumber = 1;
                enRePage.search();
            });
            //分页事件
            $('#epp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('epp'); //定制化分页
                    enRePage.pageSize = pageSize; enRePage.pageNumber = pageNumber;
                    enRePage.search();
                }
            });
            //绑定分页go按钮
            $('#pageGoEn').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                enRePage.pageNumber = pageNumber;
                enRePage.search();
            });
            //清除按钮
            $('#btnEnReset').on("click", function () {
                enRePage.clearPage(true, true, true);
            });
            //扫描批次事件
            $('#txtEnMfgOrderName').textbox({
                onChange: function (n, o) {
                    enRePage.pageNumber = 1;
                    enRePage.search();
                }
            });
        },
        //查询
        search: function () {
            var params = {
                pageSize: rePage.pageSize,
                pageIndex: rePage.pageNumber
            };
            var datas = $("#queryForm1").serializeArray();
            $.each(datas, function () {
                params[this.name] = this.value;
            });
            var formData = {
                action: "GetRepairContainerList",
                params: JSON.stringify(params)
            };
            page.post(page.ajaxUrl, formData, true, function (res) {
                if (!res.Result) {
                    displayMessage(res.Message, res.Result);
                    return;
                }
                enRePage.pageTotal = res.RowCount;
                $("#gdReContainerInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
            });
        },
        //清除页面（查询区域，列表区域，是否清空消息）
        clearPage: function (query, list, msg) {
            if (query) {
                $("#txtEnMfgOrderName").textbox("setValue", "");
                $("#txtEnProductName").textbox("setValue", "");
                $("#txtEnContainerName").textbox("setValue", "");
                enRePage.pageNumber = 1; enRePage.pageTotal = 0
                $('#epp').pagination('refresh', {
                    total: enRePage.pageTotal,
                    pageSize: enRePage.pageSize,
                    pageNumber: enRePage.pageNumber
                });
            }
            if (list) {
                enRePage.pageNumber = 1; enRePage.pageTotal = 0
                clearEasyuiDataGrid("gdReContainerInfo"); //清空列表
            }
            if (msg) {
                clearMessage();
            }
        }
    };
    $(function () {
        page.init();
    });
</script>
